package com.cskaoyan.day4;

import java.util.Arrays;

public class ArrayCopy {
    public static void main(String[] args) {
        int arr[] = {1, 2, 3, 4, 5, 6};
        System.out.println(Arrays.toString(arrayCopy(arr, 7)));
    }

    private static int[] arrayCopy(int[] arr, int newElement) {
        int[] newArray = new int[arr.length + 1];
        System.arraycopy(arr, 0, newArray, 0, arr.length);
        newArray[arr.length] = newElement;
        return newArray;
    }
}
